<template>
  <div class="question-wrap">
    <div class="time">
      <span>{{ time }}</span>
    </div>
    <div class="form-item">
      <div class="form-label title">
        <span>描述</span>
      </div>
      <div class="form-content">
        <el-input v-model="desc" placeholder="请输入描述" :rows="3" type="textarea"/>
      </div>
    </div>
    <div class="form-item">
      <div class="form-label title">
        <span>图片</span>
      </div>
      <div class="form-content">
        <div v-for="(item, index) in pic" :key="index" class="kantan-item">
          <el-image
              :src="item"
              :preview-src-list="pic"
              :initial-index="index"
              fit="cover"
          />
        </div>
      </div>
    </div>
    <div class="form-item">
      <div class="form-label title">
        <span>视频</span>
      </div>
      <div class="form-content">
        <div v-for="(item, index) in video" :key="index" class="kantan-item">
          <video :src="item" controls/>
        </div>
      </div>
    </div>
  </div>
</template>


<script lang="ts" setup>

import {defineProps, toRefs, watch} from 'vue'

interface searchDetail {
  desc: '',
  id: 0,
  pic: [],
  video: [],
  time: ''
}


const props = defineProps<{
  detail: searchDetail,
}>()
const {desc, pic, video, time} = toRefs(props.detail)
watch(() => props.detail, (val) => {
  desc.value = val.desc
  pic.value = val.pic
  video.value = val.video
  time.value = val.time
})
</script>

<style lang="scss" scoped>
.question-wrap {
  .time {
    color: #FFFFFF;
    padding-bottom: 24px;
  }

  .form-item {
    display: flex;
    align-items: stretch;
    margin-bottom: 24px;

    .form-label {
      color: rgba(240, 245, 255, 0.95);
      width: 56px;
      margin-right: 12px;
      text-align: right;

      &.title {
        line-height: 32px;
      }

      &.content {
        line-height: 32px;
      }

      &.apply {
        line-height: 32px;
      }
    }

    .form-content {
      flex: 1;
      display: flex;
      flex-wrap: wrap;

      .el-textarea {
        --el-input-text-color: rgb(255, 255, 255);
      }

      .kantan-item {
        width: 120px;
        height: 80px;
        position: relative;
        padding-right: 8px;
        padding-bottom: 8px;
        .el-image{
          width: 120px;
          height: 80px;
        }
        img, video {
          display: block;
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}
</style>
